<?php
/**
 * pathinfo转发
 * @authors wangkang (wangkang@myhexin.com)
 * @date    2016-05-01 11:23:12
 * @version $Id$
 */

class Url
{
    static function Pathinfo()
    {
        $url = explode("/", trim($_SERVER['REQUEST_URI'], "/"));
        if ($url[1] == "admin.php" || $url[1] == "index.php") {
            $control = $url[2] ? $url[2] : "index";
            $action = $url[3] ? $url[3] : "index";
        } else if (!isset($url[1])) {
            $control = "index";
            $action = "index";
        } else {
            include '404.html';
            return;
        }
        $confile = APP_PATH.'controls/'.$control.".php";
        if (is_file($confile)) {
            include_once $confile;
        } else {
            include "404.html";
            return;
        }
        $methods = get_class_methods($control);
        if (!in_array($action.'Action', $methods)) {
            include "404.html";
            return;
        }
        $con = new $control();
        $action = $action."Action";
        $con->$action();
    }
}

